import Vue from 'vue'
import VueRouter from 'vue-router'
import Newest from '../views/Newest.vue'
import Blog from '../views/Blog.vue'
import Edit from '../views/Edit.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/blog/newest'
  },
  {
    path: '/edit',
    component: Edit
  },
  {
    path: '/blog',
    component: Blog,
    children: [
      {
        path: '',
        redirect: '/blog/newest'
      },
      {
        path: 'newest',
        name: 'Newest',
        component: Newest
      },
      {
        path: 'classify',
        name: 'Classify',
        component: () => import('../views/Classify.vue')
      },
      {
        path: 'article/:id',
        name: 'Article',
        props: true,
        component: () => import('../views/Article.vue')
      },
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
